﻿using StackExchange.Redis;

namespace TdxApiPool.Common
{
    public class RedisUtils
    {
        private static readonly object Lock = new object();

        public readonly ConnectionMultiplexer HqRedis;

        private static volatile RedisUtils _instance;

        private RedisUtils()
        {
            HqRedis = ConnectionMultiplexer.Connect(Config.GetConfig().Redis);
        }

        public static RedisUtils GetInstance()
        {
            if (null != _instance) return _instance;

            lock (Lock)
            {
                if (null == _instance)
                    _instance = new RedisUtils();
            }

            return _instance;
        }
    }
}